package com.hospital.workstation.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import lombok.RequiredArgsConstructor;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;

import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.hospital.common.annotation.RepeatSubmit;
import com.hospital.common.annotation.Log;
import com.hospital.common.core.controller.BaseController;
import com.hospital.common.core.domain.PageQuery;
import com.hospital.common.core.domain.R;
import com.hospital.common.core.validate.AddGroup;
import com.hospital.common.core.validate.EditGroup;
import com.hospital.common.core.validate.QueryGroup;
import com.hospital.common.enums.BusinessType;
import com.hospital.common.utils.poi.ExcelUtil;
import com.hospital.workstation.domain.vo.HisDocumentRetrievealVo;
import com.hospital.workstation.domain.bo.HisDocumentRetrievealBo;
import com.hospital.workstation.service.IHisDocumentRetrievealService;
import com.hospital.common.core.page.TableDataInfo;

/**
 * 检验检查报告检索
 *
 * @author whb
 * @date 2023-03-09
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/workstation/documentRetrieveal")
public class HisDocumentRetrievealController extends BaseController {

    private final IHisDocumentRetrievealService iHisDocumentRetrievealService;

    /**
     * 查询检验检查报告检索列表
     */
    @SaCheckPermission("workstation:documentRetrieveal:list")
    @GetMapping("/list")
    public TableDataInfo<HisDocumentRetrievealVo> list(HisDocumentRetrievealBo bo, PageQuery pageQuery) {
        return iHisDocumentRetrievealService.queryPageList(bo, pageQuery);
    }

    /**
     * 获取检验检查报告检索详细信息
     *
     * @param id 主键
     */
    @SaCheckPermission("workstation:documentRetrieveal:query")
    @GetMapping("/{id}")
    public R<HisDocumentRetrievealVo> getInfo(@NotNull(message = "主键不能为空")
                                              @PathVariable Long id) {
        return R.ok(iHisDocumentRetrievealService.queryById(id));
    }

    /**
     * 新增检验检查报告检索
     */
    @SaCheckPermission("workstation:documentRetrieveal:add")
    @Log(title = "检验检查报告检索", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HisDocumentRetrievealBo bo) {
        return toAjax(iHisDocumentRetrievealService.insertByBo(bo));
    }

    /**
     * 修改检验检查报告检索
     */
    @SaCheckPermission("workstation:documentRetrieveal:edit")
    @Log(title = "检验检查报告检索", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HisDocumentRetrievealBo bo) {
        return toAjax(iHisDocumentRetrievealService.updateByBo(bo));
    }

    /**
     * 删除检验检查报告检索
     *
     * @param ids 主键串
     */
    /*@SaCheckPermission("workstation:documentRetrieveal:remove")
    @Log(title = "检验检查报告检索", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(iHisDocumentRetrievealService.deleteWithValidByIds(Arrays.asList(ids), true));
    }*/
}
